function $$(_this){
   return new Base(_this); 
}

function Base(_this){

    this.elements = [];
    if(_this != undefined){
     this.elements.push(_this);   
    }
  
}
Base.prototype.getTagName = function(name,id,o){
        var node = null;
        if(arguments.length == 3){
            node = o;
        }
        else
        if(arguments.length == 2){
            node = document.getElementById(id); 
        }else{
            node = document;
        }
        if(node != null){
            var objs = node.getElementsByTagName(name);
            for(var i = 0;i < objs.length;i++){
                this.elements.push(objs[i]);
            }    
        }
        return this;
}
Base.prototype.getIdO = function(id){
    return document.getElementById(id);
}
Base.prototype.getId = function(id){
      this.elements.push(document.getElementById(id));
      return this;       
}
Base.prototype.css = function(attr,value){
    
    for(var i = 0;i < this.elements.length;i++){
        if(arguments.length == 1){
            if(typeof window.getComputedStyle != "undefined"){//w3c
                return window.getComputedStyle(this.elements[i],null)[attr];
                
            }else if(typeof this.elements[i].currentStyle != "undefined"){//ie
                return this.elements[i].currentStyle[attr];
            }
        }
        this.elements[i].style[attr] = value;
    }   
   return this;   
}
Base.prototype.html = function (value){
    for(var i = 0;i < this.elements.length;i++){
        if(arguments.length == 0){
            return this.elements[0].innerHTML;
        }
        this.elements[i].innerHTML = value;
    }   
   return this;
}
Base.prototype.click = function (fn){
    for(var i = 0;i < this.elements.length;i++){
        this.addEvent(this.elements[i],"click",fn);
    }   
   return this;       
}

Base.prototype.setElements = function(els){
    this.elements = [];
    for(var i = 0;i<els.length;i++){
        this.elements.push(els[i]);
    }
    return this;   
}
Base.prototype.getElements = function(num){
   if(num == undefined){
      return this.elements;
   }
   var elm = this.elements[num];
   this.elements = [];
   this.elements[0] = elm;
   return this;
}
Base.prototype.setClass = function(name){
    for(var i = 0;i < this.elements.length;i++){
        
        this.elements[i].className = name;
        
    }
    return this;    
}
Base.prototype.addClass = function(name){
    
    for(var i = 0;i < this.elements.length;i++){
        if(!this.elements[i].className.match(new RegExp('(\\s|^)'+name+'(\\s|$)'))){
            this.elements[i].className += ' ' + name;
        }
    }
    return this;
}
Base.prototype.removeClass = function(name){
    var n ;
    for(var i = 0;i < this.elements.length;i++){
           n =  this.elements[i].className;
           n = n.replace(name,'');
           n = n.replace(' ','');
        this.elements[i].className = n;
    }
    return this;
}
Base.prototype.getClass = function(name,idName){
    var node = null;
    if(arguments.length == 2){
        node = document.getElementById(idName);
    }else{
        node = document;
    }
    var tags  = node.getElementsByTagName("*");
    for(var i = 0;i < tags.length;i++){
         if(tags[i].className.indexOf(name)!= -1){
            this.elements.push(tags[i]);
         }
    }
    return this;
}
Base.prototype.addEvents = function(type,fn){
    for(var i = 0;i < this.elements.length;i++){
        this.addEvent(this.elements[i],type,fn);
    }
    return this;
}
Base.prototype.addEvent = function(elem,type,fn){
    
         if(elem.attachEvent){//ie
            elem.attachEvent("on"+type,function(){
            fn.call(elem);
          });
       }else if(elem.addEventListener){
          elem.addEventListener(type,fn,false);
         }     
    
    return this;
}
Base.prototype.getAllElements = function(){
    
    return this.elements;
}
Base.prototype.hover = function(over,out){
    for(var i = 0;i < this.elements.length;i++){
       
        this.addEvent(this.elements[i],"mouseover",over);
        this.addEvent(this.elements[i],"mouseout",out);
        
    }
    return this;
}
Base.prototype.show = function(status){
    
    for(var i = 0;i < this.elements.length;i++){
        if(arguments.length == 1){
           return this.elements[i].style.display == "block" || this.elements[i].style.display == ""?true:false;
        }
        this.elements[i].style.display = "block";
    }
    return this;    
}
Base.prototype.hide = function(){
    for(var i = 0;i < this.elements.length;i++){
        this.elements[i].style.display = "none";
    }
    return this;    
}
Base.prototype.parent = function(elem){
       if(elem.attachEvent){//ie
        return elem.parentElement;
       }else if(elem.addEventListener){
         return elem.parentNode;   
       }  
}
